//
//  IndividualSettingViewController.m
//  Gxj
//
//  Created by 💋索少杰 on 2017/9/19.
//  Copyright © 2017年 wkq. All rights reserved.
//

#import "IndividualSettingViewController.h"

@interface IndividualSettingViewController ()<UITableViewDelegate,UITableViewDataSource>

@property(nonatomic, strong) UITableView * tableView;

@end

@implementation IndividualSettingViewController

- (void)viewWillAppear:(BOOL)animated
{
    self.navigationController.navigationBarHidden = NO;
}

- (void)viewDidLoad {
    [super viewDidLoad];
    self.view.backgroundColor=[UIColor whiteColor];
    
    self.title = @"设置";
    self.view.backgroundColor = [UIColor whiteColor];
    self.automaticallyAdjustsScrollViewInsets = NO;
    self.navigationController.navigationBar.translucent = YES;
    self.navigationController.navigationBar.titleTextAttributes = @{NSForegroundColorAttributeName:[UIColor whiteColor],NSFontAttributeName:[UIFont boldSystemFontOfSize:17]};
    [self.navigationController.navigationBar setBackgroundImage:[UIImage imageNamed:@"bg"]forBarMetrics:UIBarMetricsDefault];
    //返回按钮
    UIButton * leftBtn = [UIButton buttonWithType:UIButtonTypeSystem];
    leftBtn.frame = CGRectMake(0, 0, kWidthScale(15),kHeightScale(20));
    [leftBtn setBackgroundImage:[UIImage imageNamed:@"fanhui1"] forState:UIControlStateNormal];
    leftBtn.contentMode = UIViewContentModeScaleAspectFit;
    [leftBtn addTarget:self action:@selector(leftBarBtnClicked:) forControlEvents:UIControlEventTouchUpInside];
    self.navigationItem.leftBarButtonItem = [[UIBarButtonItem alloc]initWithCustomView:leftBtn];
    //表格设置
    [self setTableViewUp];
}
- (void)leftBarBtnClicked:(UIButton *)btn
{
    [self.navigationController popViewControllerAnimated:YES];
}
- (void)setTableViewUp{
    
    _tableView=[[UITableView alloc] initWithFrame:CGRectMake(0, kHeightScale(54), UIScreenWidth, UIScreenHeight) style:UITableViewStylePlain];
    _tableView.delegate=self;
    _tableView.dataSource=self;
    self.tableView.tableFooterView = [[UIView alloc] init];
    self.tableView.separatorStyle = UITableViewCellSeparatorStyleNone;// 去掉所有cell的分割线
    [self.view addSubview:_tableView];
}

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
    //松手即取消点击效果
    [self.tableView deselectRowAtIndexPath:indexPath animated:YES];
}

//返回每个分区下的单元格个数，必须实现
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
    
    if (section==0) {
        return 2;//第一组有1行
    }else if (section == 1){
        return 1;
    }
    else if (section==2) {
        return 1;//第二组不定 （按数据展示）
    }else if (section == 3){
        return 3;
    }else{
        return 1;
    }
}
//返回每个分区的个数
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{
    return 5;
}
- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section{
    if (section == 0) {
        return kHeightScale(20);
    }else if (section == 1){
        return kHeightScale(10);
    }else if (section == 2){
        return kHeightScale(10);
    }else if (section == 3){
        return kHeightScale(10);
    }else{
        return kHeightScale(10);
    }
}

//设置对应位置的cell的高度
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
    if (indexPath.section  == 3 && indexPath.row==0) {
        
        return kHeightScale(60);
    }else{
        return kHeightScale(50);
    }
}
- (UITableViewCell*)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
    static NSString * str=@"biao";
    UITableViewCell * cell=[tableView dequeueReusableCellWithIdentifier:str];
    if (!cell) {
        cell=[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:str];
//        cell.selectionStyle = UITableViewCellSelectionStyleNone;
        cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
    }
    if (indexPath.section == 0 && indexPath.row==0 ) {
        cell.textLabel.text=@"账号安全";
    }if(indexPath.section == 0 && indexPath.row==1 ){
        cell.textLabel.text=@"通知提醒";
    }if(indexPath.section == 1 && indexPath.row==0){
        cell.textLabel.text=@"清除缓存";
    }if(indexPath.section == 2 && indexPath.row==0){
        cell.textLabel.text=@"水印添加";
    }
    if(indexPath.section == 3 && indexPath.row==0){
        cell.textLabel.text=@"帮助与反馈";
    }
    if(indexPath.section == 3 && indexPath.row==1){
        cell.textLabel.text=@"检查更新";
    }if (indexPath.section == 3 && indexPath.row==2) {
        cell.textLabel.text=@"关于共想家";
    }
    if(indexPath.section == 4 && indexPath.row==0){
        cell.textLabel.text=@"退出登录";
        cell.textLabel.textColor=[UIColor redColor];
        cell.textLabel.textAlignment=YES;
        cell.accessoryType = UITableViewCellAccessoryNone;
    }
    
    return cell;
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
